package atmGUI;

import util.Util;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

//登录
public class LoginPanel extends JPanel implements ActionListener {
    private Icon loginImage = Util.getIcon("/image/buttonLand.jpg");//登陆按钮图
    private JButton loginBtn;
    private ATM_GUI_Main frame;//顶级容器实例

    public LoginPanel(ATM_GUI_Main frame) {
        this.frame = frame;
        //设置空布局和透明度
        this.setLayout(null);
        this.setOpaque(false);
        //登陆按钮
        loginBtn = new JButton(loginImage);//登录按钮
        loginBtn.setBounds(230, 420, 140, 50);
        this.add(loginBtn);
        loginBtn.addActionListener(this);//建立联系
    }

    @Override
    public void actionPerformed(ActionEvent e) {//当点击登录按钮时，切换到菜单界面
        if (e.getSource()==loginBtn) {
            frame.switchPanel("menu");
        }
    }
}
